<?php
/**
 *
 *
 */
namespace app\admin\controller;
use think\Controller;
use think\Db;
class File extends Common
{
    public function index()
    {

        return view();
    }
    public function delete()
    {
        $id = input('id');
        $m = input('m');
        $time =fun_sc_p('file', array('id'=>$id), 'create_time');
        $savename =fun_sc_p('file', array('id'=>$id), 'savename');
        $thumb=fun_sc_p('file', array('id'=>$id), 'sha1');
        $ext=fun_sc_p('file', array('id'=>$id), 'ext');
        $data = $this->request->get();
        if (Db::name($m)->where('id', $id)->data($data)->delete($data)) {
            unlink(ROOT_PATH . '/uploads/'.date('Ymd',$time).'/'.$savename);
            unlink(ROOT_PATH . '/uploads/thumb/'.$thumb.'thumb.'.$ext);
            $this->success('删除成功');
        } else {
            $this->error('删除失败');
        }
    }
}